
#pragma once

#include "zdbmain.h"
#include "zdbents.h"

#pragma warning( disable: 4275 4251 )

#ifdef SCENEOE
#define LIGHTDLLIMPEXP __declspec(dllexport)
#else
#define LIGHTDLLIMPEXP
#endif

#include "zdbgrip.h"
#include "zAcGiLightTraits.h"

class UcDbImpLight;

class LIGHTDLLIMPEXP UcDbLight : public UcDbEntity
{
public:
    UCRX_DECLARE_MEMBERS(UcDbLight);

private:
    static ZSoft::UInt32 kCurrentVersionNumber ;
public:
    UcDbLight ();
    ~UcDbLight();

    virtual Ucad::ErrorStatus subClose();
    virtual Ucad::ErrorStatus dwgOutFields (UcDbDwgFiler *pFiler) const ;
    virtual Ucad::ErrorStatus dwgInFields (UcDbDwgFiler *pFiler) ;

    virtual Ucad::ErrorStatus   getOsnapPoints(
                                 UcDb::OsnapMode     osnapMode,
                                 ZSoft::GsMarker     gsSelectionMark,
                                 const UcGePoint3d&  pickPoint,
                                 const UcGePoint3d&  lastPoint,
                                 const UcGeMatrix3d& viewXform,
                                 UcGePoint3dArray&   snapPoints,
                                 UcDbIntArray &   geomIds) const;

    virtual Ucad::ErrorStatus   getOsnapPoints(
                                 UcDb::OsnapMode     osnapMode,
                                 ZSoft::GsMarker     gsSelectionMark,
                                 const UcGePoint3d&  pickPoint,
                                 const UcGePoint3d&  lastPoint,
                                 const UcGeMatrix3d& viewXform,
                                 UcGePoint3dArray&   snapPoints,
                                 UcDbIntArray &   geomIds,
                                 const UcGeMatrix3d& insertionMat) const;

    virtual Ucad::ErrorStatus getGripPoints (UcDbGripDataPtrArray &grips, const double curViewUnitSize, const int gripSize, const UcGeVector3d &curViewDir, const int bitflags) const ;
    virtual Ucad::ErrorStatus moveGripPointsAt (const UcDbVoidPtrArray &gripAppData, const UcGeVector3d &offset, const int bitflags) ;

    virtual Ucad::ErrorStatus getClassID(CLSID* pClsid) const ;

    virtual Ucad::ErrorStatus transformBy(const UcGeMatrix3d& xform);

    virtual Ucad::ErrorStatus getTransformedCopy(const UcGeMatrix3d & xform,UcDbEntity *& pEnt) const;

    virtual Ucad::ErrorStatus dxfInFields(UcDbDxfFiler* pFiler);

    virtual Ucad::ErrorStatus dxfOutFields(UcDbDxfFiler* pFiler) const;

    virtual Ucad::ErrorStatus highlight(const UcDbFullSubentPath& subId,
        const ZSoft::Boolean highlightAll) const;

    virtual Ucad::ErrorStatus unhighlight(const UcDbFullSubentPath& subId,
        const ZSoft::Boolean highlightAll) const;
    virtual void list() const;

    virtual Ucad::ErrorStatus decomposeForSave(
            UcDb::UcDbDwgVersion ver,
            UcDbObject*& replaceObj,
            UcDbObjectId& replaceId,
            ZSoft::Boolean& exchangeXData);
    virtual void viewportDraw (UcGiViewportDraw *mode) ;
    virtual ZSoft::Boolean worldDraw (UcGiWorldDraw *mode) ;
    virtual ZSoft::UInt32  setAttributes(UcGiDrawableTraits* pTraits);
    virtual UcGiDrawable::DrawableType    drawableType() const;
    virtual bool castShadows() const;
    virtual void setCastShadows(bool newVal);
    virtual bool receiveShadows() const;
    virtual void setReceiveShadows(bool newVal);


    virtual Ucad::ErrorStatus deepClone(UcDbObject* pOwner,UcDbObject*& pClonedObject,
                                        UcDbIdMapping& idMap,ZSoft::Boolean isPrimary = true) const;

    virtual Ucad::ErrorStatus wblockClone(UcRxObject* pOwnerObject, UcDbObject*& pClonedObject,
                                        UcDbIdMapping& idMap, ZSoft::Boolean isPrimary ) const;

    virtual Ucad::ErrorStatus copyFrom (const UcRxObject* other);
    virtual Ucad::ErrorStatus getGeomExtents(UcDbExtents& extents) const;
    virtual const UcString& name() const;
    virtual Ucad::ErrorStatus setName(const UcString & name);
    virtual UcGiDrawable::DrawableType lightType() const;
    virtual Ucad::ErrorStatus setLightType(UcGiDrawable::DrawableType type);
    virtual  bool isOn() const;
    virtual Ucad::ErrorStatus setOn(bool value);
    virtual bool isPlottable() const;
    virtual Ucad::ErrorStatus setIsPlottable(bool plot);
    virtual const UcCmColor& lightColor() const;
    virtual Ucad::ErrorStatus setLightColor(const UcCmColor& color);
    virtual double intensity() const;
    virtual Ucad::ErrorStatus setIntensity(double intensity);
    virtual void setLightAttenuation(const UcGiLightAttenuation& params);
    virtual const UcGiLightAttenuation& lightAttenuation() const;
    virtual Ucad::ErrorStatus setPosition(const UcGePoint3d& pos);
    virtual const UcGePoint3d& position() const;
    virtual const UcGePoint3d& targetLocation() const;
    virtual Ucad::ErrorStatus setTargetLocation(const UcGePoint3d& newVal);
    virtual Ucad::ErrorStatus setHotspotAndFalloff(double hotspot, double falloff);
    virtual double hotspotAngle() const;
    virtual double falloffAngle() const;
    virtual const UcGeVector3d& lightDirection() const;
    virtual Ucad::ErrorStatus setLightDirection(const UcGeVector3d& lightvec);

    enum PhysicalIntensityMethod {
        kPeakIntensity = 0,
        kFlux,
        kIlluminance
    };

    UcDbLight::PhysicalIntensityMethod physicalIntensityMethod() const;
    Ucad::ErrorStatus setPhysicalIntensityMethod(UcDbLight::PhysicalIntensityMethod method);
    double physicalIntensity() const;
    Ucad::ErrorStatus setPhysicalIntensity(double physicalIntensity);
    double illuminanceDistance() const;
    Ucad::ErrorStatus setIlluminanceDistance(double distance);

    enum LampColorType {
        kKelvin = 0,
        kPreset
    };

    UcDbLight::LampColorType lampColorType() const;
    Ucad::ErrorStatus setLampColorType(UcDbLight::LampColorType colorType);
    double lampColorTemp() const;
    Ucad::ErrorStatus setLampColorTemp(double colorTemp);

    enum LampColorPreset {
        kD65White = 0,
        kFluorescent,
        kCoolWhite,
        kWhiteFluorescent,
        kDaylightFluorescent,
        kIncandescent,
        kXenon,
        kHalogen,
        kQuartz,
        kMetalHalide,
        kMercury,
        kPhosphorMercury,
        kHighPressureSodium,
        kLowPressureSodium,
        kCustom
    };

    UcDbLight::LampColorPreset lampColorPreset() const;
    Ucad::ErrorStatus setLampColorPreset(UcDbLight::LampColorPreset colorPreset);
    Ucad::ErrorStatus lampColorRGB(UcGiColorRGB& rgbColor) const;
    Ucad::ErrorStatus setLampColorRGB(UcGiColorRGB rgbColor);
    Ucad::ErrorStatus resultingColor(UcCmColor& rgbColor) const;
    Ucad::ErrorStatus webFile(UcString& webFile) const;
    Ucad::ErrorStatus setWebFile(const ZTCHAR* webFile);
    Ucad::ErrorStatus webRotation(UcGeVector3d& rotation) const;
    Ucad::ErrorStatus setWebRotation(UcGeVector3d rotation);
    bool hasTarget() const;
    Ucad::ErrorStatus setHasTarget(bool hasTarget);
    Ucad::ErrorStatus shadowParameters(UcGiShadowParameters& params) const;
    Ucad::ErrorStatus setShadowParameters(const UcGiShadowParameters& params);

private:
    friend class UcDbImpLight;
    UcDbImpLight * mpUcDbImpLight;
    bool mSelected;
};
